﻿using OnlineOpinionAnalysis.Shared.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnlineOpinionAnalysis.Shared
{
	public static class VideoHelper
	{
		public enum ValueType
		{
			Danmaku,
			Reply,
			Favorite,
			Coin,
			Share,
			Like
		}
		/// <summary>
		/// 获取视频 操作类型/播放量 的比例
		/// </summary>
		/// <param name="biliVideos"></param>
		/// <param name="type"></param>
		/// <returns></returns>
		public static double GetVideoRatio(List<BiliVideo> biliVideos,ValueType type)
		{
			double result = 0;
			foreach (var video in biliVideos)
			{
				switch (type)
				{
					case ValueType.Danmaku:
						result += (double)video.Danmaku / video.View;
						break;
					case ValueType.Reply:
						result += (double)video.Reply / video.View;
						break;
					case ValueType.Favorite:
						result += (double)video.Favorite / video.View;
						break;
					case ValueType.Coin:
						result += (double)video.Coin / video.View;
						break;
					case ValueType.Share:
						result += (double)video.Share / video.View;
						break;
					case ValueType.Like:
						result += (double)video.Like / video.View;
						break;
					default:
						break;
				}
			}
			return result/biliVideos.Count;
		}

		/// <summary>
		/// 统计视频播放量
		/// </summary>
		/// <param name="biliVideos"></param>
		/// <returns></returns>
		public static double SumVideoView(List<BiliVideo> biliVideos)
		{
			double result = 0;
			foreach (var video in biliVideos)
			{
				result += video.View;				
			}
			return result;
		}

	}
}
